home *** CD-ROM | disk | FTP | other *** search
- '*****************************************************************************
-
- 'Copyright (c) 1987,1988 Marcel Madonna
-
- 'DUMP.BAS shows how to use the HEXSTR and CHARXLAT functions. It takes
- 'the file specification entered on the command line and proceeds to dump the
- 'file to the screen.
-
- '
- ' ********************* N O T E *************************
- '
- 'This program cannot be used from the DOS prompt without Microsoft
- 'QuickBasic V4.0 and a registered copy of QBWARE.
- '
- 'To compile it, at the DOS prompt type:
-
- ' bc DUMP;
- ' link /ex /noe DUMP,,,brun40 qbware;
- ' del DUMP.obj
- ' del DUMP.map
-
- 'To run it fromthe QuickBasic development environment, type:
- '
- ' qb DUMP /l qbware
- ' [Shift] + F5
-
- ' qb disphex /l qbfunc.exe;
- ' link disphex;
- ' del disphex.obj
-
- 'DUMP is not very sophisticated and it does not use the any other QBWARE
- 'routines so it's easy to modify if you don't have QBWARE/1.
-
- 'To run it simply type:
- '
- ' DUMP AUTOEXEC.BAT
-
- 'at the DOS prompt and you will get a dump of youe AUTOEXEC.BAT file - of
- 'course it must be in the current directory.
-
- '*****************************************************************************
-
- CLS
- LOCATE 1, 1
- PRINT "DUMP - Version 1.0 (C) Copyright 1987,1988 AJM Software"
- LOCATE 3, 1
- Target.File$ = COMMAND$
- IF Target.File$ = "" THEN
- INPUT "Enter a filename:", Target.File$
- END IF
-
- ' We need an ASCIIZ string to open the file
-
- Filenum% = 1 'Just to show you a neat trick
- Reclen% = 512 'Read 512 bytes at a time
-
- OPEN Target.File$ FOR RANDOM ACCESS READ AS #Filenum% LEN = Reclen%
-
- FIELD #Filenum%, 512 AS Input.Buffer$
-
- ' If the file has no length, assume that it was just created by the previous
- ' and it was really not on the disk and should be deleted
-
- File.Len# = LOF(Filenum%) 'Need to keep File length
-
- IF File.Len# = 0 THEN
- CLOSE #Filenum%
- KILL Target.File$
- GOTO Invalid.Parameter
- END IF
-
- ' Set up the translation table so that all non-printable ASCII codes are
- ' changed to a '.'
-
- Xlat.Table$ = STRING$(256, ".") 'Initialize to all '.'
- FOR X% = 33 TO 126 'Fix all displayable codes
- MID$(Xlat.Table$, X% + 1, 1) = CHR$(X%)
- NEXT
-
- COLOR 15, 1
-
- ' Initialize some key fields
-
- Rec.Counter% = 1
- GET #Filenum%, Rec.Counter% 'Get the first record
- Text.Out$ = SPACE$(1024) 'Initailize output area
-
- ' Retrieve all records until EOF is reached
-
- WHILE NOT EOF(Filenum%) AND X$ <> CHR$(27)
- File.Len# = File.Len# - Reclen% 'Keep track of remaining bytes
- Text.In$ = Input.Buffer$ 'Cannot call with Field variables
- CALL HexStr(Text.In$, Text.Out$) 'convert this record
- CALL CharXlat(Text.In$, Xlat.Table$) 'get rid of non-ASCII
- GOSUB Display.Page
- Rec.Counter% = Rec.Counter% + 1
- GET #Filenum%, Rec.Counter% 'Get the next record
- WEND
-
- ' If we reached EOF then we need to print the last record that was retrieved
-
- IF X$ <> CHR$(27) AND File.Len# <> 0 THEN
- Text.In$ = Input.Buffer$ 'Cannot call with Field variables
- CALL HexStr(Text.In$, Text.Out$) 'convert this record
- CALL CharXlat(Text.In$, Xlat.Table$) 'get rid of non-ASCII
- MID$(Text.In$, File.Len# + 1, Reclen% - File.Len#) = SPACE$(Reclen% - File.Len#)
- MID$(Text.Out$, (File.Len# * 2) + 1, (Reclen% - File.Len#) * 2) = SPACE$((Reclen% - File.Len#) * 2)
- GOSUB Display.Page
- END IF
- CLOSE #Filenum%
-
- END
-
-
- ' Displays a page of text onto the screen
-
-
-
- Display.Page:
-
- CLS 'Clear screen
- LOCATE 1, 1
- PRINT Target.File$; TAB(50); "Relative Sector "; Rec.Counter%
-
- Hex.Text% = 1
- Chr.Text% = 1
- Buffer.Count% = 1
-
- FOR Line.Count% = 1 TO 22 'Max characters on a page
- Output.Line$ = SPACE$(80) 'Clear output line
-
- FOR Line.Control% = 0 TO 5 'Groups on a line
- MID$(Output.Line$, (Line.Control% * 8) + Line.Control% + 1, 8) = MID$(Text.Out$, Hex.Text%, 8)
- Hex.Text% = Hex.Text% + 8
- NEXT Line.Control%
-
-
- MID$(Output.Line$, 55, 24) = MID$(Text.In$, Chr.Text%, 24)
- Chr.Text% = Chr.Text% + 24
- PRINT Output.Line$
- NEXT Line.Count%
-
- LOCATE 24, 20: PRINT "Press any key to continue - [Esc] to end";
- X$ = ""
- WHILE X$ = ""
- X$ = INKEY$
- WEND
-
- RETURN
-
- Invalid.Parameter:
- PRINT Target.File$ + " not found"
- END
-
-